From: vhanquez@kneesa.uk.xensource.com Date: Thu, 11 May 2006 14:01:54 +0000 (+0100) Subject: Try to create runtime xenstored's directories at startup time. X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~16047^2~84 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/success//%22http:/www.example.com/cgi/success/?a=commitdiff_plain;h=acd5a62ae9c9fb33baf0314b659c9dce74176f49;p=xen.git Try to create runtime xenstored's directories at startup time. Signed-off-by: Vincent Hanquez --- diff --git a/tools/xenstore/xenstored_core.c b/tools/xenstore/xenstored_core.c index a79e2dcf0c..2dcf9cf591 100644 --- a/tools/xenstore/xenstored_core.c +++ b/tools/xenstore/xenstored_core.c @@ -1811,6 +1811,21 @@ int main(int argc, char *argv[]) reopen_log(); + /* make sure xenstored directory exists */ + if (mkdir(xs_daemon_rundir(), 0755)) { + if (errno != EEXIST) { + perror("error: mkdir daemon rundir"); + exit(-1); + } + } + + if (mkdir(xs_daemon_rootdir(), 0755)) { + if (errno != EEXIST) { + perror("error: mkdir daemon rootdir"); + exit(-1); + } + } + if (dofork) { openlog("xenstored", 0, LOG_DAEMON); daemonize(); diff --git a/tools/xenstore/xs_lib.c b/tools/xenstore/xs_lib.c index 226a8487f7..750d1823cf 100644 --- a/tools/xenstore/xs_lib.c +++ b/tools/xenstore/xs_lib.c @@ -26,13 +26,13 @@ /* Common routines for the Xen store daemon and client library. */ -static const char *xs_daemon_rootdir(void) +const char *xs_daemon_rootdir(void) { char *s = getenv("XENSTORED_ROOTDIR"); return (s ? s : "/var/lib/xenstored"); } -static const char *xs_daemon_rundir(void) +const char *xs_daemon_rundir(void) { char *s = getenv("XENSTORED_RUNDIR"); return (s ? s : "/var/run/xenstored"); diff --git a/tools/xenstore/xs_lib.h b/tools/xenstore/xs_lib.h index c62c457e61..f55008281a 100644 --- a/tools/xenstore/xs_lib.h +++ b/tools/xenstore/xs_lib.h @@ -46,6 +46,8 @@ struct xs_permissions #define MAX_STRLEN(x) ((sizeof(x) * CHAR_BIT + CHAR_BIT-1) / 10 * 3 + 2) /* Path for various daemon things: env vars can override. */ +const char *xs_daemon_rootdir(void); +const char *xs_daemon_rundir(void); const char *xs_daemon_socket(void); const char *xs_daemon_socket_ro(void); const char *xs_domain_dev(void);